*final update 2025.02.03



********************************************************************************
//STEP 01: CREATE LOCALS
********************************************************************************
*Directory to the Alpha_Do_File .do file's location
local 	home_folder "/Users/demattee/Desktop/JLC_Replication"

local MA		"5"					// What is MA's id_city? UNSURE: tab id_city if hearing_base_city=="BOS", nolab
local units		"24"				// How many jurisdictions are there?

//IDENTIFY THE STATING DATES
local begin		"1"					// The first id_time in the analysis
local MSPEstart "1"					// Period in which MSPE minimization begins 														
		
//IDENTIFY THE TREATMENT DATES
local pretreat	"38"				// What id_time corresponds with the Brito vs. Barr decision date
local decision	"39"				// Brito vs. Barr opinion published (Wednesday, Nov 27, 2019).
										// id_time	time	date_day
										// 32		201948	2019.11.27
									// court orders that immigration courts shall follow the requirements, effective Friday, December 13, 2019.
										// id_time	time	date_day
										// 34		201950	2019.12.13
local posttreat "40"				// What is the first id_time after the decision date? UNSURE: decision +1

//IDENTIFY THE ENDING DATES
local endtime	"52"				// id_time 53==2020 week 12 (Friday, March 20th) as the last id_time in the analysis?
local covid		"52"				// POTUS Declares COVID-19 a National Emergency (Friday, March 13).
		
********************************************************************************
cd "`home_folder'/Data/Placebo Results Granted Bond/Weekly"	

	foreach i of numlist 1/`units' {
		use "synth_`i'.dta", clear	 
	
	keep if week >= `MSPEstart'	// drops months not part of the MPSE minimization period

	browse
		gen 	spe_`i'= diff_`i'^2
		gen		posttreat	= 0 if week < `decision'
		gen		unit 		= `i'
		replace	posttreat	= 1 if week > `decision'	
		drop if week == `decision'
		
		collapse (mean) unit mspe_`i'=spe_`i', by(posttreat)
		reshape wide mspe_`i', i(unit) j(posttreat)

		gen		postpre_ratio	= mspe_`i'1/mspe_`i'0
		drop 	mspe*
		save	MSPEratio_`i', replace
		}
			
	use MSPEratio_`MA', clear
	foreach i of numlist 1/4 6/`units' {	 
		qui append using "MSPEratio_`i'.dta"
	}
	save "MSPEratio_bond_weekly.dta", replace
	
		histogram 	postpre_ratio, 												///
					xline(2.1720212, lwidth(thick) lpattern(dash))				///
					bin(20) start(0) frequency fcolor(gs12%70) 					///
		title("Granted Bond Rate Posttreatment/Pretreatment MSPE Ratio (HBC Week)", size(small)) 	///
					subtitle("") caption("") note("$S_DATE", size(tiny) span)						///
					ytitle(, size(small)) ylabel(, labsize(small)) ymtick(##1) 						///
					xtitle(Posttreatment/Pretreatment MSPE Ratio) 									///
					xtitle(, size(small)) xlabel(, labsize(small)) xmtick(##5)
		graph save "Graph" 	"`home_folder'/Graphs/ratios_bond_weekly.gph", replace
		graph export 		"`home_folder'/Graphs/ratios_bond_weekly.jpg", as(jpg) name("Graph") replace
		
		
********************************************************************************

local MA		"5"					// What is MA's id_city? UNSURE: tab id_city if hearing_base_city=="BOS", nolab
local units		"24"				// How many jurisdictions are there?

//IDENTIFY THE STATING DATES
local begin		"1"					// The first id_time in the analysis
local MSPEstart "1"					// Period in which MSPE minimization begins 														
		
//IDENTIFY THE TREATMENT DATES
local pretreat	"38"				// What id_time corresponds with the Brito vs. Barr decision date
local decision	"39"				// Brito vs. Barr opinion published (Wednesday, Nov 27, 2019).
										// id_time	time	date_day
										// 32		201948	2019.11.27
									// court orders that immigration courts shall follow the requirements, effective Friday, December 13, 2019.
										// id_time	time	date_day
										// 34		201950	2019.12.13
local posttreat "40"				// What is the first id_time after the decision date? UNSURE: decision +1

//IDENTIFY THE ENDING DATES
local endtime	"52"				// id_time 53==2020 week 12 (Friday, March 20th) as the last id_time in the analysis?
local covid		"52"				// POTUS Declares COVID-19 a National Emergency (Friday, March 13).

********************************************************************************
cd "`home_folder'/Data/Placebo Results Caseload/Weekly"		
	foreach i of numlist 1/`units' {
		use "synth_`i'.dta", clear	 

	keep if week >= `MSPEstart'	// drops months not part of the MPSE minimization period

	browse
		gen 	spe_`i'= diff_`i'^2
		gen		posttreat	= 0 if week < `decision'
		gen		unit 		= `i'
		replace	posttreat	= 1 if week > `decision'	
		drop if week == `decision'
		
		collapse (mean) unit mspe_`i'=spe_`i', by(posttreat)
		reshape wide mspe_`i', i(unit) j(posttreat)

		gen		postpre_ratio	= mspe_`i'1/mspe_`i'0
		drop 	mspe*
		save	MSPEratio_`i', replace
		}
			
	use MSPEratio_`MA', clear
	foreach i of numlist 1/4 6/`units' {	 
		qui append using "MSPEratio_`i'.dta"
	}
	save "MSPEratio_caseload_weekly.dta", replace

		histogram 	postpre_ratio, 												///
					xline(1.2284482, lwidth(thick) lpattern(dash))				///
					bin(20) start(0) frequency fcolor(gs12%70) 					///
					title("Caseload Posttreatment/Pretreatment MSPE Ratio (City-Week)", size(small)) 			///
					subtitle("") caption("") note("$S_DATE", size(tiny) span)						///
					ytitle(, size(small)) ylabel(, labsize(small)) ymtick(##1) 						///
					xtitle(Posttreatment/Pretreatment MSPE Ratio) 									///
					xtitle(, size(small)) xlabel(, labsize(small)) xmtick(##5)
		graph save "Graph" 	"`home_folder'/Graphs/ratios_caseload_weekly.gph", replace
		graph export 		"`home_folder'/Graphs/ratios_caseload_weekly.jpg", as(jpg) name("Graph") replace
	
